// 商品锁
package lock

import (
	"fmt"
	"strings"
)

const orderLockPrefix = "ying_shop_order"

type OrderLock struct {
	baseLock
}

func (orderLock OrderLock) GetLockName() string {
	lockString := make([]string, 0)
	lockString = append(lockString, orderLockPrefix)
	lockString = append(lockString, fmt.Sprint(orderLock.ItemId))
	return strings.Join(lockString, "_")
}

func GetOrderProductLock(orderId int) OrderLock {
	orderLock := OrderLock{}
	orderLock.ItemId = orderId
	orderLock.init(orderLock.GetLockName())
	return orderLock
}
